/**
 * Created By zhangQ 2018/4/23
 * [mysql数据库链接类]
 */
import mysql from 'mysql'

function DBServer () {
  // 添加链接
  this.addConn = function (connParam) {
    return new Promise((resolve, reject) => {
      // 创建链接
      let conn = mysql.createConnection({
        host: connParam.host,
        user: connParam.user,
        password: connParam.password,
        database: connParam.database,
        port: connParam.port
      })
      conn.connect((err) => {
        if (err) {
        } else {
          resolve(conn)
        }
      })
    })
  }
}

export default DBServer
